<template>
    <div style="background-color: white;height: 500px;padding-left: 10px;padding-top: 5px;margin-top: 10px">
      <h1>基本信息</h1>
      <hr>
      <br>
      <br>
      订单编号：<el-input v-model="tOrderbasicinfo.orderId" placeholder="请输入内容" style="width: 400px" :disabled="true"></el-input> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
      客户名称：<el-input v-model="tOrderbasicinfo.username" placeholder="请输入内容" style="width: 400px"></el-input>
      <br>
      <br>
      <br>
      <br>
      订单类型：
      <template>
        <el-select v-model="tOrderbasicinfo.typeName" placeholder="请选择" style="width: 400px">
          <el-option
            v-for="item in ordertypes"
            :key="item.typeId"
            :label="item.typeName"
            :value="item.typeName">
          </el-option>
        </el-select>
      </template>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
      创建人：&nbsp;&nbsp;&nbsp;&nbsp;<el-input v-model="tOrderbasicinfo.admin" placeholder="请输入内容" style="width: 400px"></el-input>
      <br>
      <br>
      <br>
      <br>
      创建时间：
      <el-date-picker value-format="yyyy-MM-dd HH:mm:ss" style="width: 400px" v-model="tOrderbasicinfo.receiveTime" type="datetime"></el-date-picker>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
      订单来源：
      <template>
        <el-select v-model="tOrderbasicinfo.orderfrom" placeholder="请选择" style="width: 400px">
          <el-option
            v-for="item in orderfroms"
            :key="item.fromId"
            :label="item.fromName"
            :value="item.fromName">
          </el-option>
        </el-select>
      </template>
      <br>
      <br>
      <br>
      <br>

      <el-button type="danger" round style="width: 100px" @click="save" id="save">保存</el-button>
    </div>
</template>

<script>
    export default {
        name: "rbasicinfo",
      data(){
          return {
            ordertypes:[
              {typeName: '运输订单',
                typeId:1
              },
              {
                typeName: '配送订单',
                typeId:2
              }
            ],
            orderfroms:[
              {fromName: '手动录入',
                fromId:1
              },
              {
                fromName: '扫码',
                fromId:2
              }
            ],
            tOrderbasicinfo:{
              orderId:'',
              username:'',
              typeName:'',
              admin:'',
              receiveTime:'',
              orderfrom:''
            },
            orderId:'',
          }
      },
      methods: {
        load(){

          this.$http({
            method: "GET",
            url: "http://localhost:8090/tOrderbasicinfo",
          }).then(resp => {
            console.log(resp);
            this.tOrderbasicinfo=resp.data.data.tOrderbasicinfo;
          })
        },
          getAId(){
            this.$http({
              method: "GET",
              url: "http://localhost:8090/tOrderbasicinfo/getid",
            }).then(resp => {
              console.log(resp);
              console.log(resp.data);
              this.tOrderbasicinfo.orderId=resp.data;
              this.orderId=resp.data;
              console.log(this.tOrderbasicinfo.orderId);
            })

          },
          save(){

            this.$http({
              method: "POST",
              url: "http://localhost:8090/tOrderbasicinfo",
              data: this.tOrderbasicinfo
            }).then(resp => {
              let id=this.tOrderbasicinfo.orderId;
              alert(resp.data.msg);
              this.$router.push(`/home/creatorder/addrinfo/${id}`);

            });

          }
      },
      created() {
          this.getAId();
          this.load();
      }
    }
</script>

<style scoped>
    #save{
      float: right;
      margin-right: 220px;
    }
</style>
